package com.atguigu.edu.realtime.publisher.controller;

import com.atguigu.edu.realtime.publisher.bean.AnswerQuesCnt;
import com.atguigu.edu.realtime.publisher.bean.ExamCnt;
import com.atguigu.edu.realtime.publisher.bean.PaperScoreDur;
import com.atguigu.edu.realtime.publisher.service.ExamCountService;
import com.atguigu.edu.realtime.publisher.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ExamCountController {
    @Autowired
    ExamCountService examCountService;

    @RequestMapping("/paper")
    public String getPaperCnt(@RequestParam(value = "date", defaultValue = "1")Integer date){
        if (date == 1){
            date = DateUtil.now();
        }
        List<ExamCnt> paperCnt = examCountService.getPaperCnt(date);
        return "";
    }

    @RequestMapping("/examcourse")
    public String getCourseCnt(@RequestParam(value = "date", defaultValue = "1") Integer date){
        if (date == 1){
            date = DateUtil.now();
        }
        List<ExamCnt> courseCnt = examCountService.getCourseCnt(date);
        return "";
    }

    @RequestMapping("/paperscoredur")
    public String getPaperScoreDur(@RequestParam(value = "date", defaultValue = "1") Integer date){
        if(date == 1){
            date = DateUtil.now();
        }
        List<PaperScoreDur> paperScoreDur = examCountService.getPaperScoreDur(date);
        return "";
    }

    @RequestMapping("/answer")
    public String getAnswerQuesCnt(@RequestParam(value = "date", defaultValue = "1") Integer date){
        if(date == 1){
            date = DateUtil.now();
        }
        List<AnswerQuesCnt> answerQuesCnt = examCountService.getAnswerQuesCnt(date);
        return "";
    }
}
